package com.adjaisd.mqtt.testJava;

import com.adjaisd.mqtt.entity.Device;
import com.adjaisd.mqtt.mapper.DeviceMapper;
import com.adjaisd.mqtt.service.DeviceService;
import com.adjaisd.mqtt.service.RedisService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class test {

    @Autowired
    RedisService redisService;

    @Autowired
    DeviceMapper deviceMapper;

    @Autowired
    DeviceService deviceService;

    @Test
    void testRedis() {
//        String key = "testKey";
//        String val = "testVal1wdga";
//        redisService.set(key, val, 5);
//        System.out.println(redisService.get(key));
        Object o = redisService.get("device2");
        boolean equals = o.equals("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJbnRlbFNjYXJlY3JvdyIsImlhdCI6MTY0OTUxNjc1MiwiZXhwIjoxNjQ5NTIwMzUyLCJpZCI6MiwidXNlcm5hbWUiOiJyYXNwYmVycnkiLCJwYXNzd29yZCI6IjEwMDAxIiwic2FsdCI6IjY2NiJ9.XCkRpbQwza4kcnTt4VmctPnCjTf5D-YKdlf6DdV3fzQ");
        System.out.println(equals);
        // curl -H "Content-Type: application/json" -X POST -d '{"username": "raspberry", "password":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJbnRlbFNjYXJlY3JvdyIsImlhdCI6MTY0OTUxNjc1MiwiZXhwIjoxNjQ5NTIwMzUyLCJpZCI6MiwidXNlcm5hbWUiOiJyYXNwYmVycnkiLCJwYXNzd29yZCI6IjEwMDAxIiwic2FsdCI6IjY2NiJ9.XCkRpbQwza4kcnTt4VmctPnCjTf5D-YKdlf6DdV3fzQ"}' "http://192.168.0.1:13244/mqtt/auth"
//        eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJJbnRlbFNjYXJlY3JvdyIsImlhdCI6MTY0OTUxNjc1MiwiZXhwIjoxNjQ5NTIwMzUyLCJpZCI6MiwidXNlcm5hbWUiOiJyYXNwYmVycnkiLCJwYXNzd29yZCI6IjEwMDAxIiwic2FsdCI6IjY2NiJ9.XCkRpbQwza4kcnTt4VmctPnCjTf5D-YKdlf6DdV3fzQ
    }

    @Test
    void testMySql(){
        Wrapper<Device> wrapper = new QueryWrapper<>();
        List<Device> devices = deviceMapper.selectList(wrapper);
        System.out.println(devices);
    }
}